package main.java.indi.zyj.designmodel.singleton;



/**
 * @Description     懒汉式，就是在需要调用的时候再创建类的实例化。
 * @author zyj
 * @date 2024/05/09 15:14
 */
class Singleton2 {

    private static Singleton2 instance;

    private Singleton2() {}

    //synchronized同步处理
    public static synchronized Singleton2 getInstance() {
        if(instance == null) {
            instance = new Singleton2();
        }
        return instance;
    }
}